﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
public partial class backmanage_API_A_Game : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Expires = -1;
        string returnStr = string.Empty;
        string typeStr = Request.Form["edit"].ToString();
        switch (typeStr)
        {
            case "add":
                {
                    returnStr = GameAdd();
                    break;
                }
            case "update":
                {
                    break;
                }
            case "list":
                {
                    returnStr = GameList();
                    break;
                }
            default: break;
        }

        Response.Write(returnStr);
    }
    protected string GameAdd()
    {
        string returnStr = string.Empty;
        MODEL.GameMaster model = new MODEL.GameMaster();
        BLL.GameMaster bll= new BLL.GameMaster();
        model.GNAME = Request.Form["n"];
        model.GCOMPANY = Request.Form["c"];
        model.GCREATETIME = DateTime.Now;
        model.GDOWNLOAD = Request.Form["d"];
        model.GGAMELOGO = Request.Form["l"];
        model.GMONEY = Convert.ToInt32(Request.Form["m"]);
        model.GREGISTER = Request.Form["r"];
        model.GSTATE = Request.Form["s"];
        model.GURL = Request.Form["u"];
        bool flag = bll.GameMasterAdd(model);
        if (flag)
        {
            returnStr = "{\"msg\":\"true\"}";
        }
        else
        {
            returnStr = "{\"msg\":\"false\"}";
        }

        return returnStr;
    }
    protected string GameList()
    {
        StringBuilder returnStr = new StringBuilder();
        DataSet ds = new BLL.GameMaster().GameMasterList();
        
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            returnStr.Append("<tr>");
            returnStr.Append("<td>" + dr["Gname"].ToString() + "</td>");
            returnStr.Append("<td>" + dr["Gcompany"].ToString() + "</td>");
            returnStr.Append("<td><img alt=\"" + dr["Gname"].ToString() + "\" src=\"" + dr["Ggamelogo"].ToString() + "\" /></td>");
            returnStr.Append("<td>" + dr["Gurl"].ToString() + "</td>");
            returnStr.Append("<td>" + dr["Gregister"].ToString() + "</td>");
            returnStr.Append("<td>" + dr["Gdownload"].ToString() + "</td>");
            returnStr.Append("<td>" + dr["Gmoney"].ToString() + "</td>");
            returnStr.Append("<td><a href=\"#\">修改</a></td>");
            returnStr.Append("</tr>");
        }
        return returnStr.ToString();
        
    }
}
